﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;

namespace klogger1
{
   public class FireWall1
    {
       public static void AddAppToFireWall(string ruleName, string applicationPath)
       {
           string command = string.Format("AdvFirewall Firewall add rule name={0} dir=in program={1} remoteip=localsubnet action=allow",
             ruleName,
             applicationPath);
           ProcessStartInfo psi = new ProcessStartInfo(Environment.SystemDirectory+@"\netsh.exe",command)
           {
               CreateNoWindow = true,
               WindowStyle = ProcessWindowStyle.Hidden,
               UseShellExecute = false,
               RedirectStandardOutput = true
           };
           Process.Start(psi);
       }
    }
}
